package com.zk.monitormanagement.utils;

import android.widget.Toast;

import com.zk.monitormanagement.app.MyApplication;


/**
 *
 */
public class ToastUtil {

    private static Toast toast;//实现不管我们触发多少次Toast调用，都只会持续一次Toast显示的时长
//    public static void show(int resId) {
//        show(MyApplication.getInstance().getString(resId));
//    }

    public static void show(String msg) {
        if(MyApplication.getContext() != null) {
            if (toast == null) {
                toast = Toast.makeText(MyApplication.getContext(), msg, Toast.LENGTH_SHORT);
            } else {
                toast.setText(msg);
            }
//            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
        }
    }

    public static void shortShow(String msg) {
        if(MyApplication.getContext() != null) {
            if (toast == null) {
                toast = Toast.makeText(MyApplication.getContext(), msg, Toast.LENGTH_SHORT);
            } else {
                toast.setText(msg);
            }
//            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
        }
      
    }


}
